<template>
	<view>
		<view class="actionList">
			<view class="formGroup">
			<view class="formItem">
				<view class="formLabel">姓名</view>
				<input type="text" placeholder="请输入您的姓名" class="wq-ipt1" v-model="username"></input>
			</view>
			<view class="formItem">
			<button class="wq-btn" @tap="save">保存</button>
			</view>
			</view>
		</view>
	</view>
</template>

<script>
	import api from '@/api.js'
	export default {
		data() {
			return {
				username:'',
			}
		},
		onLoad(e){
			api.doRequest('get','my/info').then(res=>{
				if(res.statusCode==200){
					this.username=res.data.data.username;
				}
			})
		},
		methods: {
			save(){
				api.doRequest("post",'my/changeInfo',{username:this.username}).then(res=>{
					if(res.statusCode==200){
						uni.showToast({
							title:"修改成功",
							icon:"none"
						})
						setTimeout(function(){
							uni.reLaunch({
								url:'/pages/my/my'
							})
						},500);
						
					}
				})
			}
		}
	}
</script>

<style>
.formGroup {
		width: 670upx;
		padding: 20upx;
		margin: 0upx auto;
		margin-bottom: 20upx;
		background: #fff;
		border-radius: 20upx;
	}
	.formLabel {
		font-size: 12px;
		margin: 20upx 0;
	}
	.formItem{
		margin-bottom:20upx;
	}
	.wq-ipt1{
		width:calc(100% - 20upx);border:1upx solid #ccc;height:80upx;border-radius:10upx;padding-left:20upx;
	}
</style>
